package imper.graphic.listener;

import imper.engine.entity.Country;
import imper.engine.entity.Industry;
import imper.engine.entity.IndustryType;
import imper.engine.util.ParameterManager;
import imper.engine.util.ProductionUtil;
import imper.graphic.view.IndustryView;

public class AddIndustryListener implements Runnable
{
	protected IndustryType _industryType;

	protected IndustryView _view;

	public AddIndustryListener(IndustryType pIndustryType, IndustryView pView)
	{
		this._industryType = pIndustryType;
		this._view = pView;
	}

	@Override
	public void run()
	{
		Country country = ParameterManager.getInstance().getMainCountry();
		Industry industry = country.getIndustry().get(_industryType.getId());
		if( industry != null)
		{
			//int newValue = ;
			//if (ProductionUtil.isAutorise(industry, _industryType, country))
			//{
				industry.setProduct(industry.getProduct() + 1);
				ProductionUtil.calculateIndustry( country);
				this._view.refreshView();
			//}
		}
		else
		{
			System.out.println(_industryType.getId());
			for( Industry indus : country.getIndustry().values())
			{
				System.out.println(indus.getIndustryId());
			}
		}

	}

}
